package 算法.NiuKe;


import java.util.ArrayDeque;
import java.util.Queue;
/**
 * @author:谢君臣
 * @Date:2021/10/9-16:23
 * @version:1.0
 * @function:
 */
public class 二叉树镜像反转 {
    public TreeNode Mirror (TreeNode pRoot) {
        // write code here
        Queue<TreeNode> queue = new ArrayDeque<>();
        queue.add(pRoot);
        while (!queue.isEmpty())
        {
            TreeNode node = queue.poll();
            TreeNode left = node.left;
            TreeNode right = node.right;
            node.left = right;
            node.right = left;
            if (left!=null)
                queue.add(left);
            if (right!=null)
                queue.add(right);
        }
        return pRoot;
    }
}
